﻿<UserControl x:Class="SQLDataTransferer.Views.TransferView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:ctrl="clr-namespace:SQLDataTransferer.Controls"
             xmlns:behaviours="clr-namespace:SQLDataTransferer.Controls.Behaviours"
             xmlns:converters="clr-namespace:SQLDataTransferer.Converters">
    <UserControl.Resources>
        <converters:RadioButtonCheckedConverter x:Key="mConverter"/>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <!--<HOST Grid>-->
        <GroupBox x:Name="grpBxHostSettings"
                  Header="Settings" 
                  VerticalAlignment="Top"
                  Margin="0,0,2,4">
            <GroupItem>
                <!-- Settings Layout -->
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <!--Server/Database controls-->
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Label Content="Server:" 
                               VerticalContentAlignment="Center"
                               VerticalAlignment="Center"/>
                        <ComboBox x:Name="cboHostServers"
                                  Grid.Column="1"
                                  Height="22"
                                  SelectedItem="{Binding Path=SelectedServer}"
                                  ItemsSource="{Binding Path=Servers}"
                                  DisplayMemberPath="FullName"                                 
                                  IsEditable="True"
                                  behaviours:ComboBoxBehaviours.TextChangedCommand="{Binding HostServerTextChangedCommand}"
                                  behaviours:ComboBoxBehaviours.LostFocusCommand="{Binding HostServerTextChangedCommand}" 
                                  Margin="0,3,0,3" 
                                  VerticalAlignment="Top" />
                        <Label Grid.Row="1"
                               Margin="0 0 11 0"
                               Content="Database:"
                               VerticalAlignment="Center"
                               VerticalContentAlignment="Center"/>
                        <ComboBox x:Name="cboHostDatabases"
                                  Grid.Row="1"
                                  Grid.Column="1"
                                  Height="22"
                                  Margin="0,0,0,3"
                                  SelectedItem="{Binding Path=SelectedDb}"
                                  ItemsSource="{Binding Path=Databases}"
                                  DisplayMemberPath="Name"
                                  IsEditable="True"
                                  behaviours:ComboBoxBehaviours.LostFocusCommand="{Binding HostDatabaseTextChangedCommand}"
                                  behaviours:ComboBoxBehaviours.SelectionChangedCommand="{Binding HostDatabaseTextChangedCommand}"/>
                        <ctrl:ExtendedButtonImage x:Name="btnRefreshServers"
                                                  Grid.Column="2"
                                                  Width="22"
                                                  Height="22"
                                                  ToolTip="Refresh servers"
                                                  Margin="6,3,0,0"
                                                  ImageSource="/SQLDataTransferer;component/Images/server_database.png"
                                                  Template="{StaticResource btnImg}"
                                                  behaviours:ButtonBehaviours.ButtonClickCommand="{Binding ServersRefreshCommand}" 
                                                  VerticalAlignment="Top">
                        </ctrl:ExtendedButtonImage>
                        <ctrl:ExtendedButtonImage x:Name="btnRefreshDatabases" 
                                                  Grid.Row="1" 
                                                  Grid.Column="2" 
                                                  Width="22" 
                                                  Height="22"
                                                  Margin="6,0,0,3"
                                                  ToolTip="Refresh databases"
                                                  Template="{StaticResource btnImg}"
                                                  ImageSource="/SQLDataTransferer;component/Images/database_refresh.png"
                                                  behaviours:ButtonBehaviours.ButtonClickCommand="{Binding DatabasesRefreshCommand}">
                        </ctrl:ExtendedButtonImage>
                    </Grid>
                    <!-- Log On to server Group -->
                    <GroupBox x:Name="grpBxHostAuthentication" 
                              Grid.Row="1"
                              Header="Log on to server" 
                              VerticalAlignment="Top" 
                              FocusManager.FocusedElement="{Binding ElementName=rdbSqlHostAuth}">
                        <GroupItem>
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height="*"/>
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                <RadioButton x:Name="rdbWindowsHostAuth"
                                             Grid.ColumnSpan="2"
                                             GroupName="Windows"
                                             IsChecked="{Binding Path=CurrentOption, Mode=TwoWay, Converter={StaticResource mConverter}, ConverterParameter=Windows}"
                                             Margin="3"
                                             Content="Use Windows Authentication" />
                                <RadioButton x:Name="rdbSqlHostAuth"
                                             Grid.Row="1"
                                             Grid.ColumnSpan="2"
                                             Margin="3,0,3,3"
                                             Content="Use SQL Authentication"
                                             GroupName="Sql"
                                             IsChecked="{Binding Path=CurrentOption, Mode=TwoWay, Converter={StaticResource mConverter}, ConverterParameter=Sql}"/>
                                <Label Grid.Row="2"
                                       Margin="13 0"
                                       Content="User name:"
                                       VerticalAlignment="Center"
                                       VerticalContentAlignment="Center"/>
                                <TextBox x:Name="txtHostUserName"
                                         Grid.Row="2"
                                         Grid.Column="1"
                                         Height="22"
                                         Margin="3,0,3,3"                                         
                                         Text="{Binding HostSqlUserName, BindsDirectlyToSource=True}"
                                         IsEnabled="{Binding ElementName=rdbSqlHostAuth, Path=IsChecked}" />
                                <Label Grid.Row="3"
                                       Margin="13 0"
                                       Content="Password:"                                       
                                       VerticalAlignment="Center"
                                       VerticalContentAlignment="Center"/>
                                <TextBox x:Name="txtHostPassword"
                                         Grid.Row="3"
                                         Grid.Column="1"
                                         Height="22"
                                         Margin="3,0,3,3"
                                         Text="{Binding HostSqlPassword, BindsDirectlyToSource=True}"
                                         IsEnabled="{Binding ElementName=rdbSqlHostAuth, Path=IsChecked}" />
                            </Grid>
                        </GroupItem>
                    </GroupBox>
                </Grid>
            </GroupItem>
        </GroupBox>
        <!--<HOST /Grid>-->
        <!--<DESTINATION Grid>-->
        <GroupBox x:Name="grpBxDestinationSettings"
                  Header="Destination Settings" 
                  VerticalAlignment="Top"
                  Grid.Column="1"
                  Margin="2,0,0,4">
            <GroupItem>
                <!-- Settings Layout -->
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <!--Server/Database controls-->
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Label Content="Server:" 
                               VerticalContentAlignment="Center"
                               VerticalAlignment="Center"/>
                        <ComboBox x:Name="cboDestinationServers"
                                  Grid.Column="1"
                                  Height="22"
                                  Margin="0,3,0,3"                        
                                  ItemsSource="{Binding Path=TargetServers}"
                                  SelectedValue="{Binding Path=SelectedServer_target}"
                                  DisplayMemberPath="FullName"                                  
                                  IsEditable="True"
                                  behaviours:ComboBoxBehaviours.TextChangedCommand="{Binding DestinationServerTextChangedCommand}"
                                  behaviours:ComboBoxBehaviours.LostFocusCommand="{Binding DestinationServerTextChangedCommand}"/>
                        <Label Grid.Row="1"
                               Margin="0 0 11 0"
                               Content="Database:"                               
                               VerticalAlignment="Center"
                               VerticalContentAlignment="Center"/>
                        <ComboBox x:Name="cboDestinationDatabases"
                                  Grid.Row="1"
                                  Grid.Column="1"
                                  Height="22"
                                  Margin="0,0,0,3"
                                  SelectedItem="{Binding Path=SelectedDb_target}"
                                  ItemsSource="{Binding Path=TargetDatabases}"
                                  DisplayMemberPath="Name"                                  
                                  IsEditable="True"                                  
                                  behaviours:ComboBoxBehaviours.TextChangedCommand="{Binding DestinationDatabaseTextChangedCommand}"
                                  behaviours:ComboBoxBehaviours.LostFocusCommand="{Binding DestinationDatabaseTextChangedCommand}" />
                        <ctrl:ExtendedButtonImage x:Name="btnRefreshDestinationServers"
                                                  Grid.Column="2"
                                                  Width="22"
                                                  Height="22"
                                                  Margin="6,0,0,0"
                                                  ToolTip="Refresh servers"
                                                  ImageSource="/SQLDataTransferer;component/Images/server_database.png"
                                                  Template="{StaticResource btnImg}"
                                                  behaviours:ButtonBehaviours.ButtonClickCommand="{Binding TargetServersRefreshCommand}">
                        </ctrl:ExtendedButtonImage>
                        <ctrl:ExtendedButtonImage x:Name="btnRefreshDestinationDatabases" 
                                                  Grid.Row="1" 
                                                  Grid.Column="2" 
                                                  Width="22" 
                                                  Height="22"
                                                  Margin="6,0,0,3"
                                                  ToolTip="Refresh databases"
                                                  ImageSource="/SQLDataTransferer;component/Images/database_refresh.png"
                                                  Template="{StaticResource btnImg}"
                                                  behaviours:ButtonBehaviours.ButtonClickCommand="{Binding TargetDatabasesRefreshCommand}">
                        </ctrl:ExtendedButtonImage>
                    </Grid>
                    <!-- Log On to server Group -->
                    <GroupBox x:Name="grpBxDestinationAuthentication" 
                              Grid.Row="1"
                              Header="Log on to server" 
                              VerticalAlignment="Top"
                              FocusManager.FocusedElement="{Binding ElementName=rdbSqlDestinationAuth}">
                        <GroupItem>
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height="*"/>
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                <RadioButton x:Name="rdbWindowsDestinationAuth"
                                             Grid.ColumnSpan="2"
                                             GroupName="WindowsDestination"
                                             Margin="3"
                                             Content="Use Windows Authentication"
                                             IsChecked="{Binding Path=CurrentOptionDestination, Mode=TwoWay, Converter={StaticResource mConverter}, ConverterParameter=Windows}"/>
                                <RadioButton x:Name="rdbSqlDestinationAuth"
                                             Grid.Row="1"
                                             Grid.ColumnSpan="2"                                                                                          
                                             Margin="3,0,3,3"
                                             Content="Use SQL Authentication"
                                             GroupName="SqlDestination"
                                             IsChecked="{Binding Path=CurrentOptionDestination, Mode=TwoWay, Converter={StaticResource mConverter}, ConverterParameter=Sql}"/>
                                <Label Grid.Row="2"
                                       Margin="13 0"
                                       Content="User name:"                                       
                                       VerticalAlignment="Center"
                                       VerticalContentAlignment="Center"/>
                                <TextBox x:Name="txtDestinationUserName"
                                         Grid.Row="2"
                                         Grid.Column="1"
                                         Height="22"
                                         Margin="3,0,3,3"
                                         Text="{Binding DestinationSqlUserName, BindsDirectlyToSource=True}"
                                         IsEnabled="{Binding ElementName=rdbSqlDestinationAuth, Path=IsChecked}" />
                                <Label Grid.Row="3"
                                       Margin="13 0"
                                       Content="Password:"
                                       VerticalAlignment="Center"
                                       VerticalContentAlignment="Center"/>
                                <TextBox Grid.Row="3"
                                         Grid.Column="1"
                                         Height="22"
                                         Margin="3,0,3,3"
                                         Text="{Binding DestinationSqlPassword, BindsDirectlyToSource=True}"
                                         IsEnabled="{Binding ElementName=rdbSqlDestinationAuth, Path=IsChecked}"/>
                            </Grid>
                        </GroupItem>
                    </GroupBox>
                </Grid>
            </GroupItem>
        </GroupBox>
        <!--<DESTINATION /Grid>-->

        <GroupBox Header="Transfer"
                  Grid.Row="1"                  
                  Grid.ColumnSpan="2">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <DockPanel>
                    <Button Content="Cancel"
                            Width="120"
                            Height="25"
                            Margin="5 5 2.5 5"
                            HorizontalAlignment="Right" 
                            DockPanel.Dock="Right"
                            IsEnabled="{Binding CancelEnabled}"
                            Command="{Binding CloseCommand}"/>
                    <Button Content="Transfer" 
                            Width="120"
                            Height="25"
                            Margin="0 5 0 5"                            
                            HorizontalAlignment="Right"
                            DockPanel.Dock="Right"
                            Command="{Binding TransferCommand}"/>
                    <Label DockPanel.Dock="Left"
                           HorizontalAlignment="Left"
                           VerticalAlignment="Bottom"
                           Content="Status:"/>
                </DockPanel>
                <Border Grid.Row="1"
                        CornerRadius="2"
                        Padding="2"
                        Style="{StaticResource bBorder}">
                    <TextBox IsReadOnly="True"
                             BorderBrush="Transparent"
                             Background="Transparent"
                             Text="{Binding Status}"
                             ScrollViewer.CanContentScroll="True"
                             ScrollViewer.HorizontalScrollBarVisibility="Auto"
                             ScrollViewer.VerticalScrollBarVisibility="Auto">
                    </TextBox>
                </Border>
            </Grid>
        </GroupBox>
    </Grid>
</UserControl>
